const mongoose = require('mongoose')
const Schema = mongoose.Schema
const MessageSchemaConfig = {
  versionKey: false,
  timestamps: {
    createdAt: 'created_at',
    updatedAt: false
  }
}

const MessageSchema = new Schema({
  send_to: { type: Schema.Types.ObjectId, ref: 'User' },
  send_from: { type: Schema.Types.Mixed }, // system: 0, others: <UserObjectId>
  title: String,
  direction: String,
  read: { type: Boolean, default: false },
  delete: { type: Boolean, default: false }
}, MessageSchemaConfig)

exports = module.exports = MessageSchema
